home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / xreversi / xreversi.frm < prev    next >
Text File  |  1995-12-10  |  30KB  |  1,053 lines

  1. VERSION 2.00
  2. Begin Form XReversi 
  3.    BackColor       =   &H0000FF00&
  4.    Caption         =   "Extended Reversi"
  5.    ClientHeight    =   3960
  6.    ClientLeft      =   1470
  7.    ClientTop       =   1845
  8.    ClientWidth     =   7425
  9.    Height          =   4650
  10.    Icon            =   XREVERSI.FRX:0000
  11.    Left            =   1410
  12.    LinkMode        =   1  'Source
  13.    LinkTopic       =   "Form1"
  14.    ScaleHeight     =   3960
  15.    ScaleWidth      =   7425
  16.    Top             =   1215
  17.    Width           =   7545
  18.    Begin CommandButton buttonHumanForfeit 
  19.       Caption         =   "Forfeit Move"
  20.       Height          =   495
  21.       Left            =   5760
  22.       TabIndex        =   7
  23.       Top             =   2160
  24.       Width           =   1215
  25.    End
  26.    Begin CommandButton buttonComputerMove 
  27.       Caption         =   "Make Move"
  28.       Height          =   495
  29.       Left            =   4200
  30.       TabIndex        =   6
  31.       Top             =   2160
  32.       Width           =   1215
  33.    End
  34.    Begin PictureBox MoveMsg 
  35.       BackColor       =   &H00FFFF00&
  36.       Height          =   975
  37.       Left            =   3960
  38.       ScaleHeight     =   945
  39.       ScaleWidth      =   3225
  40.       TabIndex        =   8
  41.       Top             =   960
  42.       Width           =   3255
  43.    End
  44.    Begin PictureBox Board 
  45.       BackColor       =   &H000000FF&
  46.       Height          =   3680
  47.       Left            =   120
  48.       MousePointer    =   2  'Cross
  49.       ScaleHeight     =   3645
  50.       ScaleWidth      =   3645
  51.       TabIndex        =   0
  52.       Top             =   120
  53.       Width           =   3680
  54.    End
  55.    Begin Label HumanScore 
  56.       BorderStyle     =   1  'Fixed Single
  57.       Caption         =   "   0"
  58.       FontBold        =   -1  'True
  59.       FontItalic      =   0   'False
  60.       FontName        =   "MS Sans Serif"
  61.       FontSize        =   24
  62.       FontStrikethru  =   0   'False
  63.       FontUnderline   =   0   'False
  64.       Height          =   615
  65.       Left            =   5760
  66.       TabIndex        =   1
  67.       Top             =   3120
  68.       Width           =   1215
  69.    End
  70.    Begin Label ComputerScore 
  71.       BorderStyle     =   1  'Fixed Single
  72.       Caption         =   "   0"
  73.       FontBold        =   -1  'True
  74.       FontItalic      =   0   'False
  75.       FontName        =   "MS Sans Serif"
  76.       FontSize        =   24
  77.       FontStrikethru  =   0   'False
  78.       FontUnderline   =   0   'False
  79.       Height          =   615
  80.       Left            =   4200
  81.       TabIndex        =   2
  82.       Top             =   3120
  83.       Width           =   1215
  84.    End
  85.    Begin Label Label2 
  86.       BackColor       =   &H0000FF00&
  87.       Caption         =   "Human"
  88.       FontBold        =   -1  'True
  89.       FontItalic      =   0   'False
  90.       FontName        =   "MS Sans Serif"
  91.       FontSize        =   12
  92.       FontStrikethru  =   0   'False
  93.       FontUnderline   =   0   'False
  94.       Height          =   375
  95.       Left            =   5880
  96.       TabIndex        =   5
  97.       Top             =   2760
  98.       Width           =   855
  99.    End
  100.    Begin Label Label1 
  101.       BackColor       =   &H0000FF00&
  102.       Caption         =   "Computer"
  103.       FontBold        =   -1  'True
  104.       FontItalic      =   0   'False
  105.       FontName        =   "MS Sans Serif"
  106.       FontSize        =   12
  107.       FontStrikethru  =   0   'False
  108.       FontUnderline   =   0   'False
  109.       Height          =   375
  110.       Left            =   4200
  111.       TabIndex        =   4
  112.       Top             =   2760
  113.       Width           =   1215
  114.    End
  115.    Begin Label FeedbackMsg 
  116.       BackColor       =   &H0000FFFF&
  117.       BorderStyle     =   1  'Fixed Single
  118.       Caption         =   " "
  119.       FontBold        =   -1  'True
  120.       FontItalic      =   0   'False
  121.       FontName        =   "MS Sans Serif"
  122.       FontSize        =   9.75
  123.       FontStrikethru  =   0   'False
  124.       FontUnderline   =   0   'False
  125.       Height          =   615
  126.       Left            =   3960
  127.       TabIndex        =   3
  128.       Top             =   120
  129.       Width           =   3255
  130.    End
  131.    Begin Menu menuGame 
  132.       Caption         =   "&Game"
  133.       Begin Menu menubarNewGame 
  134.          Caption         =   "&New Game"
  135.       End
  136.       Begin Menu menusepG1 
  137.          Caption         =   "-"
  138.       End
  139.       Begin Menu menubarModern 
  140.          Caption         =   "&Modern Opening"
  141.       End
  142.       Begin Menu menubarRandom 
  143.          Caption         =   "&Random Opening"
  144.       End
  145.       Begin Menu menusepG2 
  146.          Caption         =   "-"
  147.       End
  148.       Begin Menu menubar8x8 
  149.          Caption         =   "&8 x 8 Board"
  150.       End
  151.       Begin Menu menubar10x10 
  152.          Caption         =   "&10 x 10 Boad"
  153.       End
  154.       Begin Menu menubar16x16 
  155.          Caption         =   "1&6 x 16 Board"
  156.       End
  157.       Begin Menu menubar20x20 
  158.          Caption         =   "&20 x 20 Board"
  159.       End
  160.       Begin Menu menusepG3 
  161.          Caption         =   "-"
  162.       End
  163.       Begin Menu menubarQuit 
  164.          Caption         =   "&Quit"
  165.       End
  166.    End
  167.    Begin Menu menuOptions 
  168.       Caption         =   "&Options"
  169.       Begin Menu menubarWhite 
  170.          Caption         =   "&White for Human"
  171.       End
  172.       Begin Menu menubarBlack 
  173.          Caption         =   "&Black for Human"
  174.       End
  175.       Begin Menu menusepO1 
  176.          Caption         =   "-"
  177.       End
  178.       Begin Menu menubarHuman 
  179.          Caption         =   "&Human 1st"
  180.       End
  181.       Begin Menu menubarComputer 
  182.          Caption         =   "&Computer 1st"
  183.       End
  184.    End
  185.    Begin Menu menuSkill 
  186.       Caption         =   "&Skill"
  187.       Begin Menu menubarSkill 
  188.          Caption         =   "&Expert Computer"
  189.          Index           =   0
  190.       End
  191.       Begin Menu menubarSkill 
  192.          Caption         =   "&Good Computer"
  193.          Index           =   1
  194.       End
  195.       Begin Menu menubarSkill 
  196.          Caption         =   "&Fair Computer"
  197.          Index           =   2
  198.       End
  199.       Begin Menu menubarSkill 
  200.          Caption         =   "&Poor Computer"
  201.          Index           =   3
  202.       End
  203.       Begin Menu menubarSkill 
  204.          Caption         =   "&Idiot Computer"
  205.          Index           =   4
  206.       End
  207.    End
  208. End
  209. DefStr A-Z  ' Force numeric variables to be declared
  210.  
  211. Dim CRLF$   ' CarriageReturn/LineFeed pair
  212.  
  213. Dim CurrPlayer As Integer, ModernOpening As Integer  ' Boolean
  214. Dim MoveNoise As Integer
  215.  
  216. Dim BoardGrid() As String * 1, BoardPc(HUMAN To COMPUTER) As String * 1
  217. Dim DescPc(HUMAN To COMPUTER) As String
  218. Dim Score(HUMAN To COMPUTER) As Integer
  219.  
  220. Dim TurnNbr As Integer, NbrPcs As Integer
  221. Dim ForfeitCount As Integer
  222. Dim GameOver As Integer  ' Boolean
  223.  
  224. Dim MaxRC As Integer, MaxIJ As Integer, MidRC As Integer
  225. Dim MaxPcs As Integer
  226.  
  227. ' Raw position values
  228. Dim Rating(MIN_RC To MAX_RATING_RC, MIN_RC To MAX_RATING_RC) As Long
  229.  
  230. ' Multiplier for # turned pieces in line opposite empty square
  231. Dim XEmpty(MIN_RC To MAX_RATING_RC, MIN_RC To MAX_RATING_RC) As Long
  232.  
  233. ' "Neutralize" (neither + nor -) # turned pieces opposite border
  234. Dim XBorder(MIN_RC To MAX_RATING_RC, MIN_RC To MAX_RATING_RC) As Long
  235.  
  236. ' Multiplier for # turned pieces opposite opponent's piece
  237. Dim XOpponent(MIN_RC To MAX_RATING_RC, MIN_RC To MAX_RATING_RC) As Long
  238.  
  239. ' Translation of radial direction value into X and Y coordinate increments
  240. Dim RowIncr(MIN_DIR To MAX_DIR) As Integer
  241. Dim ColIncr(MIN_DIR To MAX_DIR) As Integer
  242.  
  243. ' Adjust scores and total pieces after a move
  244. Sub AdjustScores (ByVal P%, ByVal N%)
  245.     SetScore P%, (Score(P%) + N% + 1)  ' Include new piece
  246.     SetScore (Not P%), (Score(Not P%) - N%)
  247.     NbrPcs = Score(HUMAN) + Score(COMPUTER)
  248. End Sub
  249.  
  250. ' Trigger Human's move on "MouseUp" instead of "Click" to get X & Y
  251. Sub Board_MouseUp (Button As Integer, Shift As Integer, x As Single, y As Single)
  252.     Dim cs As Single
  253.     Dim r%, c%
  254.  
  255.     cs = CellSize()
  256.  
  257.     r% = 1 + Int(y / cs)
  258.     c% = 1 + Int(x / cs)
  259.     
  260.     MoveForHuman r%, c%
  261. End Sub
  262.  
  263. Sub Board_Paint ()
  264.     ShowGrid
  265.     ShowPcs
  266. End Sub
  267.  
  268. Sub buttonComputerMove_Click ()
  269.